package com.example.pages;

import static org.openqa.selenium.support.ui.ExpectedConditions.alertIsPresent;

import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;

public class InternalPage extends AnyPage {
	
	@FindBy(xpath ="//*[@id='wrapper']/header/div/nav/ul/li[1]/a")
	public WebElement menuHomeLink;
	
	@FindBy(xpath ="//*[@id='wrapper']/header/div/nav/ul/li[4]/a")
	public WebElement menuLogoutLink;
	
	@FindBy(xpath ="//*[@id='wrapper']/header/div/nav/ul/li[2]/a")
	public WebElement menuMyProfileLink;
	
	@FindBy(xpath ="//*[@id='wrapper']/header/div/nav/ul/li[3]/a")
	public WebElement menuUserManagementLink;
	
	public boolean isOnThisPage() {
		return menuLogoutLink.isDisplayed();
	}
	public void logout() {
		menuLogoutLink.click();
		wait_().until(alertIsPresent()).accept();
	}
	
	@Override
    void tryToOpen() {
    	MyPageFactory.getPage(driver, LoginPage.class).loginWithValidCredentials("admin","admin");
    } 
	
	  public UserPage goToUserManagementConsole() {
		  menuUserManagementLink.click();
		 return MyPageFactory.getPage(driver, UserPage.class);
	}
	  
}
